#ifndef __LOG_H
#define __LOG_H

#ifdef __KERNEL__
#include <linux/printk.h>
#define gmsmx_print printk
#else
#include <stdio.h>
#define gmsmx_print printf
#endif

#ifdef DEBUG
#define log(format, ...)                                                   \
    do {                                                                   \
        gmsmx_print("[file:%s func:%s line:%d]. ", __FILE__, __FUNCTION__, \
                    __LINE__);                                             \
        gmsmx_print(format, ##__VA_ARGS__);                                \
    } while (0)
#else
#define log(format, ...)
#endif

#define print_hex(data, len)                               \
    do {                                                   \
        size_t i;                                          \
        gmsmx_print("(%s, %ld) \t0x", #data, (long)len);   \
        for (i = 0; i < len; i++)                          \
            gmsmx_print("%02X", (unsigned char)(data)[i]); \
        gmsmx_print("\n");                                 \
    } while (0)

#endif  // __LOG_H